<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 
          数组去重 ['李白', '亚瑟', '李白'] 要求去除数组中重复的元素。
          1. 遍历数组
          2. 判断当前元素是否存在新数组
          3. 添加
      */
        var hero = ['李白', '亚瑟', '李白'];
        var newHero = new Array();
        for (var i = 0; i < hero.length; i++) {

            if (newHero.indexOf(hero[i]) == -1) {
                newHero.push(hero[i])
            }
        }
        console.log(newHero);


    </script>
</body>

</html>